#include <iostream>
#include <vector>
#include ".\lib\json-3.9.1\single_include\nlohmann\json.hpp"
using json = nlohmann::json;
using namespace std;


class Solution {
public:
    char slowestKey(vector<int>& releaseTimes, string keysPressed) {
        int n = releaseTimes.size();
        char ans = keysPressed[0];
        int maxTime = releaseTimes[0];
        for (int i = 1; i < n; i++) {
            char key = keysPressed[i];
            int time = releaseTimes[i] - releaseTimes[i - 1];
            if (time > maxTime || (time == maxTime && key > ans)) {
                ans = key;
                maxTime = time;
            }
        }
        return ans;
    }
};


int main() {
    string releaseTimesInput;
    getline(cin, releaseTimesInput);
    auto releaseTimesJson = json::parse(releaseTimesInput);
    vector<int> releaseTimes = releaseTimesJson;
    string keysPressedInput;
    getline(cin, keysPressedInput);
    auto keysPressedJson = json::parse(keysPressedInput);
    string keysPressed = keysPressedJson;
    cout << Solution().slowestKey(releaseTimes, keysPressed) << endl;
}

